<template>
	<div>
	<h2 style="margin-left:380px;"><span>登录</span></h2>
	<el-row style="margin-left:300px;">
	<el-col :span="6"><div class="grid"></div>
	<el-form :model="LoginForm" ref="LoginForm" label-width="80px" class="demo-Login">
  	<el-form-item prop="name" label="用户名" :rules="{required:true,message:'请输入用户名',trigger:'blur'}">
    	<el-input v-model="LoginForm.name"></el-input>
  	</el-form-item>
  	<el-form-item prop="pass" label="密码" :rules="{required:true,message:'请输入密码',trigger:'blur'}">
  		<el-input type="password" v-model="LoginForm.pass"></el-input>
  	</el-form-item>
  	<el-form-item>
    	<el-button type="primary" @click="submitForm(LoginForm)">登录</el-button>
    	<el-button type="primary" @click="registFrom">注册</el-button>
 	 </el-form-item>
 	 </el-form>
 	 </el-col>
 	 </el-row>
	</div>
</template>

<script>
import axios from 'axios'
	export default{
		data(){
			return{
				LoginForm:{
					name:'',
					pass:''
				}
			}
		},
		methods:{
			submitForm(LoginForm) {
				let mv = this;
        		axios.get('/api/login?name=' + LoginForm.name + '&&password='+ LoginForm.pass).then(function(r){
						console.log(JSON.stringify(r));
						if(r.data.errcode == 0)
						{
							console.log('router push!');
							mv.$router.push('/homepage');
						}
				}).catch(function(error){
					console.log(error);
				});
          	},
          	registFrom(){

          	}
     	}
	}
</script>

<style>
	
</style>